package com.treasure.mall.biz.dto.community;


import com.treasure.mall.biz.dto.BaseSaveDTO;
import com.treasure.mall.biz.entity.user.UserPO;
import com.treasure.mall.zbq.common.ienum.base.CodeDescEnumHelper;
import com.treasure.mall.zbq.common.ienum.community.CommunityEnums;
import lombok.Data;

@Data
public class CommentsSaveDTO implements BaseSaveDTO {

    /**
     * 回复目标评论ID
     */
    private Long commentsId;

    /**
     * 评论内容
     */
    private String message;

    /**
     * 文章ID
     */
    private Long articleId;

    /**
     * 评论文章的类型 0 社区
     * {@link com.treasure.mall.zbq.common.ienum.community.CommunityEnums.CommentsContentType}
     */
    private int commentsArticleType = 0;

    /**
     * 发起评论用户
     */
    private UserPO replyUser;

    /**
     * 获取评论类型
     *
     * @return
     */
    public CommunityEnums.CommentsContentType commentsContentType() {
        CommunityEnums.CommentsContentType commentsContentType = CodeDescEnumHelper.getEnumTypeByCode(CommunityEnums.CommentsContentType.class, this.commentsArticleType);
        if (commentsContentType != null) {
            return commentsContentType;
        }
        return CommunityEnums.CommentsContentType.COMMUNITY_ARTICLE;
    }
}
